package com.os.sys.service.bean;

import com.os.util.BPConstants;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
 * 菜单树结点.
 * @author jecent 2014-10-10
 */
public class MenuTreeNode implements Serializable{
	private static final long serialVersionUID = 1L; 
	
	public String appUri = "/xinda";
	
	private int id = -1 ;
	   
	private String name = "";
	   
	private String isParent = "true";
	   
	private String icon = "";
	   
	private String checked ="false";
	
	private String path="";
	private String text="";
	private String img = "";
	
	public List<MenuTreeNode> items = new ArrayList();
	
	//private String url ="";
	
	public int menu_id = 0; 
	public String menu_name = "";
	public String menu_addr = "";
	public String menu_code = "";
	private int m_p;
	private String m_f = "";
	
	public List<MenuTreeNode> children = new ArrayList();
	public List<MenuTreeNode> getChildren() {
		return children;
	}
	public void setChildren(List<MenuTreeNode> children) {
		this.children = children;
	}
	public String getMenu_addr() {
		return menu_addr;
	}
	public void setMenu_addr(String menu_addr) {
		this.menu_addr = menu_addr;
	}
	public String getMenu_code() {
		return menu_code;
	}
	public void setMenu_code(String menu_code) {
		this.menu_code = menu_code;
	}
	public int getMenu_id() {
		return menu_id;
	}
	public void setMenu_id(int menu_id) {
		this.menu_id = menu_id;
	}
	public String getMenu_name() {
		return menu_name;
	}
	public void setMenu_name(String menu_name) {
		this.menu_name = menu_name;
	}
	
	public String genPintStr(){
		String Str = "";
		Str = "[(menu_id,"+menu_id+"),"+ 
		             "(menu_code,"+menu_code+")" +
		             "(menu_name,"+menu_name+"),"+ 
		             "(menu_addr,"+menu_addr+")" +
		             		"]";
		return Str;
	}
    
	public void printMe(){
		System.out.print(this.genPintStr() );
		
	}
	
	
	public String getChecked() {
		return checked;
	}
	public void setChecked(String checked) {
		this.checked = checked;
	}
	public String getIcon() {
		return icon;
	}
	public void setIcon(String icon) {
		this.icon = icon;
	}
	public int getId() {
		return menu_id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getIsParent() {
		return isParent;
	}
	public void setIsParent(String isParent) {
		this.isParent = isParent;
	}
	public String getName() {
		return menu_name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public List<MenuTreeNode> getItems() {
		return this.children;
	}
	public void setItems(List<MenuTreeNode> items) {
		this.items = items;
	}
	public String getPath() {
		if(this.menu_addr==null ){
			return "";
		}
		if(this.menu_addr.equalsIgnoreCase("") ){
			return "";
		}
		String pid_str = "&pid="+this.getM_p();
		if(this.getM_p()==0){
			pid_str="";
		}
		String result = "";
		if(menu_addr.indexOf("?")>=0){
			result = this.appUri+ this.menu_addr+"&mid="+this.getId()+pid_str+"&year="+BPConstants.DEF_YEAR;
		}else{
			result = this.appUri+ this.menu_addr+"?mid="+this.getId()+pid_str+"&year="+BPConstants.DEF_YEAR;
		}
		if(this.getM_f().length()>=4){
			result = this.appUri+"/common/frm/"+m_f+".jsp"+"?mid="+this.getId()+"&pid="+this.getM_p()+"&path="+result;
		}
//		if(this.menu_addr.indexOf("pmenu1_cont")>=0){
//			result = this.appUri+"/app/base/pmenu1.jsp"+"?mid="+this.getId()+"&pid="+this.getM_p()+"&path="+result;
//		}
		
		return result;
	}
	public void setPath(String path) {
		this.path = path;
	}
	public String getText() {
		return this.menu_name;
	}
	public void setText(String text) {
		this.text = text;
	}
	public String getAppUri() {
		return appUri;
	}
	public void setAppUri(String appUri) {
		this.appUri = appUri;
	}
	public int getM_p() {
		return m_p;
	}
	public void setM_p(int m_p) {
		this.m_p = m_p;
	}
	public String getImg() {
		return img;
	}
	public void setImg(String img) {
		this.img = img;
	}
	public String getM_f() {
		return m_f==null?"":m_f;
	}
	public void setM_f(String m_f) {
		this.m_f = m_f;
	}
	
	
	
	
//	public String getUrl() {
//		return "#";
//	}
//	
//	public void setUrl(String url) {
//		this.url = url;
//	}


	@Override
	public String toString() {
		return "MenuTreeNode{" +
				"appUri='" + appUri + '\'' +
				", id=" + id +
				", name='" + name + '\'' +
				", isParent='" + isParent + '\'' +
				", icon='" + icon + '\'' +
				", checked='" + checked + '\'' +
				", path='" + path + '\'' +
				", text='" + text + '\'' +
				", img='" + img + '\'' +
				", items=" + items +
				", menu_id=" + menu_id +
				", menu_name='" + menu_name + '\'' +
				", menu_addr='" + menu_addr + '\'' +
				", menu_code='" + menu_code + '\'' +
				", m_p=" + m_p +
				", m_f='" + m_f + '\'' +
				", children=" + children +
				'}';
	}
}
